function NuderResponse(nuderform, list) {

	if(!nuderform.formType)
		nuderform = new NuderHTMLForm(nuderform);

	var stat = 200;	
	
//	if(new TypeFromObject(form).equals(Types.INT))
//		stat = form;
	
	this.writeToStream = function(packageID, k) {
		if(stat != 200)
			ServerProxy.syncResponse(stat, packageID, k);
		else
			ServiceUtil.init(function(){
				doSubmit(packageID, k);
			});
	}
	
	this.getStatusCode = function() {
		return stat;
	}
	
	function doSubmit(packageID, k) {
		var instance = nuderform.createInstance();
		var listenerKey = ServiceUtil.generateListenerKey();		

		var params = [];
		
		params[params.length] = new TypedObject(Types.STRING, nuderform.formType);					//form type
		params[params.length] = new TypedObject(Types.STRING, packageID); 							//package id
		params[params.length] = new TypedObject(Types.INT, instance.stat? instance.stat : stat); 	//http status
		
		if (!nuderform.useNativeProgress)
			params[params.length] = new TypedObject(Types.toArray(Types.STRING), listenerKey); //non native listener key
		
		var m = new MethodHeadInit("syncHelper", params, [], new RequestHeadInit(TITTValues.POST, "/titt/", HeadFactory.EMPTY));
		
		instance.action = m.getPath();

		function end() {
			instance.stop();
		}
		
		function start() {
			k(); //must be run before submit -> otherwise listener calls doesnt get through
				 //should not be a problem as nuders usually run on different hosts
			instance.submit();
		}
		
		if (!nuderform.useNativeProgress) {
			var doEnd = end;
			var doStart = start;
			end = function(){
				doEnd();
				TITT.getService().lazyUnregister(listener, function(){});
			}
			start = function() {
				TITT.getService().register(listener, listenerKey, doStart);
			}
		}

		var listener = ServiceUtil.createListener(list, end);
		instance.listener = listener;
		start();
	}
	
	this.__titt__isNuderResponse = true;
	
}

function InternalNuderResponse(body) {
	this.getBody = function() {
		return body;
	}
	this.toString = function() {
		return body;
	}
}

/*
function NuderResponse(form, listener) {

	var stat = 200;	
	
	if(new TypeFromObject(form).equals(Types.INT))
		stat = form;
	
	this.writeToStream = function(packageID, k) {
		if(stat != 200)
			ServerProxy.syncResponse(stat, packageID, k);
		else
			ServiceUtil.init(function(){
				doSubmit(packageID, k);
			});
	}
	
	this.getStatusCode = function() {
		return stat;
	}
	
	function doSubmit(packageID, k) {
		var targets;
		
		var lKey = ServiceUtil.generateListenerKey();
		var params = [new TypedObject(Types.STRING, packageID), new TypedObject(Types.INT, stat), new TypedObject(Types.toArray(Types.STRING), lKey)];
		var m = new MethodHeadInit("syncHelper", params, [], new RequestHeadInit(TITTValues.POST, "/titt/", HeadFactory.EMPTY));
		
		ServiceUtil.setupForm(form, m.getPath(), true);

		var l = ServiceUtil.createListener(listener, function() {
			ServiceUtil.cleanUp(targets, form);
			TITT.getService().lazyUnregister(l, function(){});
		});		
		
		TITT.getService().register(l, lKey, function() {
			
			targets = ServiceUtil.createTargets(form);
			k(); //must be run before submit -> otherwise listener calls doesnt get through
				 //should not be a problem as nuders usually run on different hosts
			form.submit();
		});
	}
	
	this.__titt__isNuderResponse = true;
	
}

function InternalNuderResponse(body) {
	this.getBody = function() {
		return body;
	}
	this.toString = function() {
		return body;
	}
}

 */
